package com.bree.erp.data.xls.imp.sheet;

import javax.persistence.EntityManager;

import jxl.Sheet;

import com.bree.erp.data.xls.imp.AbstractSheet;
import com.bree.erp.service.CurrencyService;
import com.bree.erp.service.stateless.CurrencyServiceBean;

public class CurrencySheet extends AbstractSheet {

	public CurrencySheet(Sheet sheet) {
		super(sheet);
	}

	@Override
	public void importSheet(EntityManager em) {

		Sheet sheet = this.getSheet();
		CurrencyService service = new CurrencyServiceBean(em);

		em.getTransaction().begin();

		for (int row = 1; row < sheet.getRows(); row++) {
			String code = sheet.getCell(0, row).getContents().trim();
			String symbol = sheet.getCell(1, row).getContents().trim();
			String name = sheet.getCell(2, row).getContents().trim();
			
			service.create(code, symbol, name);
		}
		

		em.getTransaction().commit();
	}

}
